<?php
/**---------------------------------------------------------------------------
 * Purpose：	Get configuration info
 * 
 * CreateDate : 2012/12/25
 * Description：
 * 	Get configuration info
 * @package    C-UNIT Class
 * @author     C-UNIT SQUARE CO.,LTD. <info@c-unit.co.jp>
 * @copyright  Copyright(c) 2012　C-UNIT SQUARE CO.,LTD. All Rights Reserved.
 * @license    C-UNIT SQUARE CO.,LTD.
 ---------------------------------------------------------------------------*/
class CUnit_Config 
{
	const KEY = 'CUnit_Config_';
	
	/**
	 * Get application config object
	 * 
	 * @return Zend_Config
	 */
	public static function getConfig() 
	{
		$strHost = $_SERVER['SERVER_NAME'];
		if(substr($strHost, 0, 3) == 'www'){
			$strHost = substr($strHost, 4);
		}

		$strKey = self::KEY . $strHost;
		if (Zend_Registry::isRegistered($strKey) == false) {
			$strFile = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'application.ini';
			
			$objConfig = new Zend_Config_Ini($strFile);
			Zend_Registry::set($strKey, $objConfig);
		}
		
		return Zend_Registry::get($strKey);
	}
}
